package com.qf.dao;

import com.qf.pojo.entity.TbRolePermission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface TbRolePermissionRepository extends JpaRepository<TbRolePermission,Integer> {
    /**
     * 通过角色id查询所有权限的id
     * @param id 角色id
     * @return 权限id列表
     */
    @Query(value = "SELECT perid FROM tb_role_permission WHERE roleid = ?1",nativeQuery = true)
    List<Integer> findPermissionIdByRoleId(Integer id);
    @Modifying
    @Transactional
    @Query(value ="delete from tb_role_permission where roleid = ?1",nativeQuery = true)
    void deleteByRoleId(Integer id);
}
